package com.lsa.skienna.challenge.chap11.the111101_IsBiggerSmarter;

import java.io.IOException;
import java.io.InputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Locale;
import java.util.Scanner;

public class Main implements Runnable{
    private static final String CRLF = System.getProperty("line.separator");
    
    static void process(InputStream in, PrintStream out) {
        TaskReader taskReader = new TaskReader(in);
        try {
            Task task = taskReader.nextTask();
            out.print(solve(task));
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
    
    private static String solve(Task task) {
        Collections.sort(task.elefantsWeightAndIq, new Comparator<Elephan>() {
            @Override
            public int compare(Elephan o1, Elephan o2) {
                int result = o1.weight - o2.weight;
                if (result == 0) {
                    result = o2.IQ - o1.IQ;
                }
                return result;
            }
        });
        
        Dp[] dp = new Dp[task.elefantsWeightAndIq.size()];
        dp[0] = new Dp(1, -1);
        for (int i = 1; i < dp.length; i++) {
            Elephan e = task.elefantsWeightAndIq.get(i);
            int maxJ = -1;
            int maxLen = 0;
            for (int j = 0; j < i; j++) {
                Elephan e1 = task.elefantsWeightAndIq.get(j);
                if (e1.weight < e.weight && e1.IQ > e.IQ && maxLen < dp[j].length) {
                    maxJ = j;
                    maxLen = dp[j].length;
                }
            }
            dp[i] = new Dp(maxLen + 1, maxJ);
        }
        int maxIdx = 0;
        for (int i = 1; i < dp.length; i++) {
            if (dp[i].length >= dp[maxIdx].length) {
                maxIdx = i;
            }
        }
        
        LinkedList<Integer> elephants = new LinkedList<Integer>();
        int i = maxIdx;
        while(i > -1) {
            elephants.addFirst(task.elefantsWeightAndIq.get(i).elephanNo);
            i = dp[i].parent;
        }
        
        StringBuilder sb = new StringBuilder();
        sb.append(elephants.size());
        for (Integer elephanNo : elephants) {
            sb.append(CRLF);
            sb.append(elephanNo);
        }
        sb.append(CRLF);
        
        return sb.toString();
    }
    
    static class Dp{
        int length;
        int parent;
        
        Dp(int length, int parent) {
            this.length = length;
            this.parent = parent;
        }

        @Override
        public String toString() {
            return String.format("Dp [length=%s, parent=%s]", length, parent);
        }
    }

    static class TaskReader{
        private Scanner scanner;
        private int elephanNo;

        TaskReader(InputStream stream) {
            this.scanner = new Scanner(stream);
            scanner.useLocale(Locale.ENGLISH);
        }
        
        Task nextTask() throws IOException {
            Task task = new Task();
            
            elephanNo = 1;
            Elephan p;
            while((p = readElephan()) != null) {
                task.elefantsWeightAndIq.add(p);
            }
            
            return task;
        }
        
        Elephan readElephan() {
            if (!scanner.hasNextInt()) {
                return null;
            }
            return new Elephan(scanner.nextInt(), scanner.nextInt(), elephanNo++);
        }
    }
    
    static class Task {
        List<Elephan> elefantsWeightAndIq = new ArrayList<Elephan>();
    }
    
    static class Elephan{
        final int weight;
        final int IQ;
        final int elephanNo;
        
        Elephan(int weight, int iQ, int elephanNo) {
            this.weight = weight;
            this.IQ = iQ;
            this.elephanNo = elephanNo;
        }

        @Override
        public String toString() {
            return String.format("Elephan [weight=%s, IQ=%s, elephanNo=%s]",
                    weight, IQ, elephanNo);
        }
    }
    
    public static void main(String[] args) {
        new Main().run();
    }
    
    @Override
    public void run() {
        process(System.in, System.out);
    }
}
